<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>设备管理</title>
<!-- 导入jquery核心类库 -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link id="easyuiTheme" rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/default.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<!-- 导入ztree类库 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/js/ztree/zTreeStyle.css"
	type="text/css" />
<script
	src="${pageContext.request.contextPath }/js/ztree/jquery.ztree.all-3.5.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>
<script type="text/javascript">
	// 初始化ztree菜单
	$(function() {
		var setting = {
			data : {
				simpleData : { // 简单数据 
					enable : true
				}
			},
			callback : {
				onClick : onClick
			}
		};
		
		// 基本功能菜单加载
		$.post("${pageContext.request.contextPath}/json/menu.json",function(data){
			$.fn.zTree.init($("#treeMenu"), setting, data);
		},"json");
		
		
		// 系统管理菜单加载
		$.post("${pageContext.request.contextPath}/json/admin.json",function(data){
			$.fn.zTree.init($("#adminMenu"), setting, data);
		},"json");
		
		
		$("#btnCancel").click(function(){
			$('#editPwdWindow').window('close');
		});
		
		// 修改密码确定按钮事件 
		$("#btnEp").click(function(){
			// 校验form内容 
			var txtNewPass = $("#txtNewPass").val();
			var txtRePass = $("#txtRePass").val();
			if(txtNewPass.trim()==""){
				// 密码为空
				$.messager.alert("警告","密码不能为空（包括空白字符串）","warning");
				return ;
			}
			if(txtNewPass.trim()!= txtRePass.trim()){
				// 两次密码输入不一致
				$.messager.alert("警告","两次密码输入不一致","warning");
				return ;
			}
			// 通过校验 ，发起Ajax请求 ，修改密码 
			$.post("${pageContext.request.contextPath}/user_editpassword.action"
					,{"password":txtNewPass},function(data){
				// data 服务器返回json 转换后对象 
				if(data.success){
					// 修改密码成功
					$.messager.alert("信息","修改密码成功！","info");
				}else{
					// 修改密码失败 
					$.messager.alert("错误","修改密码失败！","error");
				}
				// 关闭修改密码窗口
				$('#editPwdWindow').window('close');
			});
		});
	});

	function onClick(event, treeId, treeNode, clickFlag) {
		// 判断树菜单节点是否含有 page属性
		if (treeNode.page!=undefined && treeNode.page!= "") {
			if ($("#tabs").tabs('exists', treeNode.name)) {// 判断tab是否存在
				$('#tabs').tabs('select', treeNode.name); // 切换tab
			} else {
				// 开启一个新的tab页面
				var content = '<div style="width:100%;height:100%;overflow:hidden;">'
						+ '<iframe src="'
						+ treeNode.page
						+ '" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';

				$('#tabs').tabs('add', {
					title : treeNode.name,
					content : content,
					closable : true
				});
			}
		}
	}

</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:60px;padding:10px;">
		<h1 align="center">设备管理</h1>
	</div>
	<div data-options="region:'west',split:true,title:'菜单导航'"
		style="width:200px">
		<div class="easyui-accordion" fit="true" border="false">
			<div title="基本功能" data-options="iconCls:'icon-mini-add'" style="overflow:auto">
				<ul id="treeMenu" class="ztree"></ul>
			</div>
			<div title="系统管理" data-options="iconCls:'icon-mini-add'" style="overflow:auto">  
				<ul id="adminMenu" class="ztree"></ul>
			</div>
		</div>
	</div>
	<div data-options="region:'center'">
		<div id="tabs" fit="true" class="easyui-tabs" border="false">
			<div title="消息中心" id="subWarp"
				style="width:100%;height:100%;overflow:hidden">
				<iframe src="page_common_home.action"
					style="width:100%;height:100%;border:0;"></iframe>
				<%--				这里显示公告栏、预警信息和代办事宜--%>
			</div>
		</div>
	</div>
	
</body>
</html>